package com.igeek.clud_system.config;

import org.springframework.boot.web.server.ConfigurableWebServerFactory;
import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;

@Configuration
public class TomcatConfiguration {


    /**
     * 替换SpringBoot应用内嵌容器的配置对象
     */
    @Bean
    public WebServerFactoryCustomizer<ConfigurableWebServerFactory> buildWebServerFactoryCustomizer(){

        return new WebServerFactoryCustomizer<ConfigurableWebServerFactory>() {
            @Override
            public void customize(ConfigurableWebServerFactory factory) {
//                //添加错误页
                factory.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND,"/404.html"));
            }
        };
    }
}
